package ecom.shell;

import java.io.PrintStream;

import shell.command.ShellCommandImpl;
import shell.command.ShellContext;

public class AdminCommandImpl extends ShellCommandImpl {

	public AdminCommandImpl(ShellContext context) {
		super(context);
	}

	@Override
	public String getName() {
		return "admin";
	}

	@Override
	public String getUsage() {
		return "admin <password>";
	}

	@Override
	public String getShortDescription() {
		return "Get administrator prompt";
	}
	
	public void execute(final String ligneDeCommande, final PrintStream out,
			final PrintStream err) {
		
		if(this.getContexte().getVar("EST_ADMIN").equals(EcomShellConstantes.OUI)){
			out.println("Vous êtes déjà administrateur");
		}else{
			this.getContexte().setVar(EcomShellConstantes.EST_ADMIN, EcomShellConstantes.OUI);
			out.println("Vous êtes maintenant administrateur");
		}
	}

}
